package com.wxc.view;

import com.wxc.common.User;
import com.wxc.thread.SendThread;
import com.wxc.util.InputUtil;
import com.wxc.util.SocketUtil;

import java.net.Socket;

/**
 * @author wxc
 * @date 2021年10月01日 17:03
 */
public class QQView {

    /**
     * @date 2021-10-01 17:04
     * 一级目录
     */
    public static void firstMenu() {
        boolean loop = true;
        while (loop) {
            System.out.println("=========QQ Client=========");
            System.out.println("\t\t 1 登入系统");
            System.out.println("\t\t 9 退出系统");
            System.out.print("请输入您的选择: ");
            String key = InputUtil.getKey();
            switch (key) {
                case "1":
                    User user = InputUtil.getUser();
                    Socket socket = SocketUtil.getSocket();
                    SendThread sendThread = new SendThread(socket, user);
                    sendThread.start();
                    try {
                        sendThread.join();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    break;
                case "9":
                    System.out.println("退出系统");
                    loop = false;
                    break;
            }
        }
    }
}
